
package example;

import client.Client;
import client.CmdClient;
import client.SocketClient;

public class SocketClientUsage {
    public static void main(String[] args) {
        CmdClient cmdClient = new CmdClient(args);

        String command = cmdClient.getCommand();
        String key = cmdClient.getKey();
        String value = cmdClient.getValue();
        String host = cmdClient.getHost();
        int port = cmdClient.getPort();
//new一个client对象
        Client client = new SocketClient(host, port);

        switch (command) {
            case "set":
                if (value == null) {
                    System.err.println("Usage: java SocketClientUsage set <key> <value>");
                    System.exit(1);
                }
                client.set(key, value);
                break;
            case "get":
                client.get(key);
                break;
            case "rm":
                client.rm(key);
                break;
            default:
                System.err.println("Invalid command: " + command);
                System.exit(1);
        }
    }
}